import requests
from lxml import etree

if __name__ == '__main__':
    # post登录url
    url = "https://miuiver.com/wp-content/plugins/erphplogin//action/login.php"
    # 模拟浏览器
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
    }
    # 发送请求参数
    cont = {
        "log": "账号",
        "pwd": "密码",
        "action": "mobantu_login"
    }
    # 登录
    session = requests.session()
    responsea = session.post(url=url, data=cont, headers=headers)
    cont2={
        "action": "epd_checkin"
    }
    # 抓取到签到并发送签到请求
    urlq="https://miuiver.com/wp-admin/admin-ajax.php"
    geren=session.post(url=urlq,data=cont2,headers=headers)
    # 抓取现在还剩多少积分
    geren2 = session.get("https://miuiver.com/user-profile/?pd=money")
    contentget=geren2.text
    tree = etree.HTML(contentget)
    paths = tree.xpath("//section/div/div/div[3]/div/p/span[1]/text()")[0]
    print(paths)
